home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / doors / access / access.c next >
Encoding:
C/C++ Source or Header  |  1992-12-26  |  2.8 KB  |  128 lines

  1. #include <exec/exec.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <dos/dos.h>
  5. #include <dos/dosextens.h>
  6. #include <proto/dos.h>
  7. #include "work:romconf/doorheader.h"
  8. #include "source:aztec/glue.h"
  9. #define Tell(x)  Seek(x,0L,OFFSET_CURRENT)
  10. ULONG GetConfBaseLine(int user);
  11. #define USERDATA 0
  12. #define CONFTOTAL 1
  13. #define CONF      2
  14.  
  15. struct ConfBase
  16. {
  17.   ULONG NewSinceDate, ConfRead,ConfYM1;
  18.   ULONG Bytes_Download,Bytes_Upload;
  19.   USHORT Upload,Downloads,RatioType,Ratio;
  20.   UWORD Access;
  21. };
  22.  
  23.  
  24. struct MyData
  25. {
  26.   int Type,Size,misc1,Version;
  27. } ;
  28. struct MasterData
  29. {
  30.    struct MyData   Code;
  31.    struct ConfBase Conf;
  32. };
  33. #define sm sendmessage
  34. #define pm prompt
  35. #define hk hotkey
  36. #define gu getuserstring
  37. int user;
  38. int conf;
  39. int conftotal=0;
  40. ULONG ConfBaseLine;
  41. void LastCommand(void);
  42. void ChangeAccess(int user,int Conf);
  43. void end(void);
  44. char BBSLoc[200];
  45. main(int argc,char *argv[])
  46. {
  47.    char temp[100];
  48.    if(argc!=2)
  49.    {
  50.      printf("Access version 1.0, written by Joseph Hodge\n");
  51.      printf("(XIM) for /X 2.30+\n");
  52.      printf("\n");
  53.      exit(0);
  54.    }
  55.    Register(argv[1][0]-'0');
  56.    sm("",1);
  57.    sm("Access version 1.0written by Joseph Hodge",1);
  58.    pm("Enter UserNum >:",temp,5);
  59.    user=atoi(temp);
  60.    pm("Enter Conference to Toggle Access >:",temp,3);
  61.    conf=atoi(temp)-1;
  62.    gu(BBSLoc,BB_LOCAL);
  63.    ConfBaseLine=GetConfBaseLine(user);
  64.    if(ConfBaseLine==0L || conf>conftotal || conf <0)
  65.    {
  66.      sm("",1);
  67.      sm("Sorry, Access impossible",1);
  68.      sprintf(temp,"Address %ld",ConfBaseLine);
  69.      sm(temp,1);
  70.      sprintf(temp,"Conference to change %d",conf);
  71.      sm(temp,1);
  72.      sprintf(temp,"TotalConf = %d",conftotal);
  73.      sm(temp,1);
  74.      ShutDown();
  75.      end();
  76.    }
  77.    ChangeAccess(user,conf);
  78.    ShutDown();
  79.    end();
  80. }
  81. void LastCommand(void)
  82. {
  83.   sm("",1);
  84. }
  85. void end(void)
  86. {
  87.   exit(0);
  88. }
  89. void ChangeAccess(int user,int Conf)
  90. {
  91.    BPTR bi;
  92.    struct MasterData t;
  93.    char temp[100];
  94.    sprintf(temp,"%sUDBase/user.%04d",BBSLoc,user);
  95.    bi=Open(temp,MODE_OLDFILE);
  96.    if(bi==NULL)
  97.    {
  98.      return;
  99.    }
  100.  
  101.    Seek(bi,ConfBaseLine+(ULONG)(sizeof(struct MasterData)*Conf),OFFSET_BEGINNING);
  102.    FRead(bi,(APTR)&t,sizeof(struct MasterData),1);
  103.    if(t.Conf.Access) t.Conf.Access=0; else t.Conf.Access=1;
  104.    Seek(bi,ConfBaseLine+(ULONG)(sizeof(struct MasterData)*Conf),OFFSET_BEGINNING);
  105.    Write(bi,(APTR)&t,sizeof(struct MasterData));
  106.    Close(bi);
  107. }
  108. ULONG GetConfBaseLine(int user)
  109. {
  110.    BPTR bi;
  111.    char temp[100];
  112.    struct MyData t;
  113.    ULONG Address;
  114.    sprintf(temp,"%sUDBase/user.%04d",BBSLoc,user);
  115.    bi=Open(temp,MODE_OLDFILE);
  116.    if(bi==NULL) return(0L);
  117.    FRead(bi,(APTR)&t,sizeof(struct MyData),1);
  118.    while(t.Type!=CONFTOTAL)
  119.    {
  120.      Seek(bi,(ULONG)t.Size,OFFSET_CURRENT);
  121.      FRead(bi,(APTR)&t,sizeof(struct MyData),1);
  122.    }
  123.    conftotal=t.misc1;
  124.    Address=Tell(bi);
  125.    Close(bi);
  126.    return(Address);
  127. }
  128.